<?php echo isset($warning) ? '<div class="alert bg-danger">'.$warning.'</div>' : "" ?>
<?php echo isset($notify) ? '<div class="alert alert-success">'.$notify.'</div>' : "" ?>
<form class="form-horizontal" role="form" method="post" action="<?=site_url('cron/history') ?>">  
  <div class="form-group">
    <label for="inputPassword3" class="col-sm-2 control-label">Tìm kiếm</label>    
    <div class="col-sm-6">
      <div class="col-sm-5">
        <input type="text" name="search" class="form-control" id="inputPassword3" placeholder="Nhập cron cần tìm.." value="<?=isset($search) ? $search : "" ?>">     
      </div>         
    </div>      
  </div>
</form>

<?php if(!empty($crons)): ?>
<div class="table-responsive">
  <table class="table table-bordered">
    <thead>
      <tr class="info" align="center">
        <td>STT</td>               
        <td>Tin nhắn</td>
        <td>Dữ liệu</td>
        <td>Ngày tạo</td>        
        <td>Tình trạng</td>                                              
      </tr>
    </thead>
    <tbody>
    <script type="text/javascript">
        var wasSubmitted = false;    
          function checkBeforeSubmit(){
            if(!wasSubmitted) {
              wasSubmitted = true;
              return wasSubmitted;
            }
            return false;
          }    
      </script>
      <?php 
        $i = 1;     
        foreach ($crons as $row):   

        $is_active = !empty($row->status) ? '<button type="button" class="btn btn-success"><span class="glyphicon glyphicon-ok-sign"></span></button>' : '<button type="button" class="btn btn-danger"><span class="glyphicon glyphicon-remove-sign"></span></button>';        
        $tr_class = empty($row->status) ? 'danger' : '';                  
          echo '<tr align="center" class="'.$tr_class.'">
                  <td>'.$i.'</td>              
                  <td>'.$row->message.'</td>              
                  <td>'.$row->cron_cat_id.'</td>
                  <td>'.$row->date_created.'</td>
                  <td>'.$is_active.'</td>                  
                </tr>';                     
          $i++;
        endforeach;
      ?>
    </tbody>
  </table>
  <?= !empty($paging_crons) ? "<div class='pull-right'><span>Tổng cộng: $total cron(s)</span><br>$paging_crons</div>" : "" ?>  
</div>		
<?php endif; ?>